{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nexport var SEARCH_MARK = '__rc_cascader_search_mark__';\nvar defaultFilter = function defaultFilter(search, options, _ref) {\n  var label = _ref.label;\n  return options.some(function (opt) {\n    return String(opt[label]).toLowerCase().includes(search.toLowerCase());\n  });\n};\nvar defaultRender = function defaultRender(inputValue, path, prefixCls, fieldNames) {\n  return path.map(function (opt) {\n    return opt[fieldNames.label];\n  }).join(' / ');\n};\nexport default (function (search, options, fieldNames, prefixCls, config, changeOnSelect) {\n  var _config$filter = config.filter,\n    filter = _config$filter === void 0 ? defaultFilter : _config$filter,\n    _config$render = config.render,\n    render = _config$render === void 0 ? defaultRender : _config$render,\n    _config$limit = config.limit,\n    limit = _config$limit === void 0 ? 50 : _config$limit,\n    sort = config.sort;\n  return React.useMemo(function () {\n    var filteredOptions = [];\n    if (!search) {\n      return [];\n    }\n    function dig(list, pathOptions) {\n      list.forEach(function (option) {\n        // Perf saving when `sort` is disabled and `limit` is provided\n        if (!sort && limit > 0 && filteredOptions.length >= limit) {\n          return;\n        }\n        var connectedPathOptions = [].concat(_toConsumableArray(pathOptions), [option]);\n        var children = option[fieldNames.children];\n        // If current option is filterable\n        if (\n        // If is leaf option\n        !children || children.length === 0 ||\n        // If is changeOnSelect\n        changeOnSelect) {\n          if (filter(search, connectedPathOptions, {\n            label: fieldNames.label\n          })) {\n            var _objectSpread2;\n            filteredOptions.push(_objectSpread(_objectSpread({}, option), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, fieldNames.label, render(search, connectedPathOptions, prefixCls, fieldNames)), _defineProperty(_objectSpread2, SEARCH_MARK, connectedPathOptions), _objectSpread2)));\n          }\n        }\n        if (children) {\n          dig(option[fieldNames.children], connectedPathOptions);\n        }\n      });\n    }\n    dig(options, []);\n    // Do sort\n    if (sort) {\n      filteredOptions.sort(function (a, b) {\n        return sort(a[SEARCH_MARK], b[SEARCH_MARK], search, fieldNames);\n      });\n    }\n    return limit > 0 ? filteredOptions.slice(0, limit) : filteredOptions;\n  }, [search, options, fieldNames, prefixCls, render, changeOnSelect, filter, sort, limit]);\n});","map":{"version":3,"names":["_defineProperty","_objectSpread","_toConsumableArray","React","SEARCH_MARK","defaultFilter","search","options","_ref","label","some","opt","String","toLowerCase","includes","defaultRender","inputValue","path","prefixCls","fieldNames","map","join","config","changeOnSelect","_config$filter","filter","_config$render","render","_config$limit","limit","sort","useMemo","filteredOptions","dig","list","pathOptions","forEach","option","length","connectedPathOptions","concat","children","_objectSpread2","push","a","b","slice"],"sources":["/data/messenger.client/node_modules/rc-cascader/es/hooks/useSearchOptions.js"],"sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nexport var SEARCH_MARK = '__rc_cascader_search_mark__';\nvar defaultFilter = function defaultFilter(search, options, _ref) {\n  var label = _ref.label;\n  return options.some(function (opt) {\n    return String(opt[label]).toLowerCase().includes(search.toLowerCase());\n  });\n};\nvar defaultRender = function defaultRender(inputValue, path, prefixCls, fieldNames) {\n  return path.map(function (opt) {\n    return opt[fieldNames.label];\n  }).join(' / ');\n};\nexport default (function (search, options, fieldNames, prefixCls, config, changeOnSelect) {\n  var _config$filter = config.filter,\n    filter = _config$filter === void 0 ? defaultFilter : _config$filter,\n    _config$render = config.render,\n    render = _config$render === void 0 ? defaultRender : _config$render,\n    _config$limit = config.limit,\n    limit = _config$limit === void 0 ? 50 : _config$limit,\n    sort = config.sort;\n  return React.useMemo(function () {\n    var filteredOptions = [];\n    if (!search) {\n      return [];\n    }\n    function dig(list, pathOptions) {\n      list.forEach(function (option) {\n        // Perf saving when `sort` is disabled and `limit` is provided\n        if (!sort && limit > 0 && filteredOptions.length >= limit) {\n          return;\n        }\n        var connectedPathOptions = [].concat(_toConsumableArray(pathOptions), [option]);\n        var children = option[fieldNames.children];\n        // If current option is filterable\n        if (\n        // If is leaf option\n        !children || children.length === 0 ||\n        // If is changeOnSelect\n        changeOnSelect) {\n          if (filter(search, connectedPathOptions, {\n            label: fieldNames.label\n          })) {\n            var _objectSpread2;\n            filteredOptions.push(_objectSpread(_objectSpread({}, option), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, fieldNames.label, render(search, connectedPathOptions, prefixCls, fieldNames)), _defineProperty(_objectSpread2, SEARCH_MARK, connectedPathOptions), _objectSpread2)));\n          }\n        }\n        if (children) {\n          dig(option[fieldNames.children], connectedPathOptions);\n        }\n      });\n    }\n    dig(options, []);\n    // Do sort\n    if (sort) {\n      filteredOptions.sort(function (a, b) {\n        return sort(a[SEARCH_MARK], b[SEARCH_MARK], search, fieldNames);\n      });\n    }\n    return limit > 0 ? filteredOptions.slice(0, limit) : filteredOptions;\n  }, [search, options, fieldNames, prefixCls, render, changeOnSelect, filter, sort, limit]);\n});"],"mappings":"AAAA,OAAOA,eAAe,MAAM,2CAA2C;AACvE,OAAOC,aAAa,MAAM,0CAA0C;AACpE,OAAOC,kBAAkB,MAAM,8CAA8C;AAC7E,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAO,IAAIC,WAAW,GAAG,6BAA6B;AACtD,IAAIC,aAAa,GAAG,SAASA,aAAa,CAACC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE;EAChE,IAAIC,KAAK,GAAGD,IAAI,CAACC,KAAK;EACtB,OAAOF,OAAO,CAACG,IAAI,CAAC,UAAUC,GAAG,EAAE;IACjC,OAAOC,MAAM,CAACD,GAAG,CAACF,KAAK,CAAC,CAAC,CAACI,WAAW,EAAE,CAACC,QAAQ,CAACR,MAAM,CAACO,WAAW,EAAE,CAAC;EACxE,CAAC,CAAC;AACJ,CAAC;AACD,IAAIE,aAAa,GAAG,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